def count_128bit_intersection(file1_path, file2_path, byteorder='big'):
    # 读取第一个文件的所有128位块，存入 set1
    set1 = set()
    with open(file1_path, 'rb') as f1:
        while True:
            chunk = f1.read(16)               # 每次读16字节:contentReference[oaicite:7]{index=7}
            if len(chunk) < 16:
                break
            num = int.from_bytes(chunk, byteorder)  # 转换为整数:contentReference[oaicite:8]{index=8}
            set1.add(num)

    # 读取第二个文件，统计交集
    intersection = set()
    with open(file2_path, 'rb') as f2:
        while True:
            chunk = f2.read(16)
            if len(chunk) < 16:
                break
            num = int.from_bytes(chunk, byteorder)
            if num in set1:                     # 集合成员测试 O(1) :contentReference[oaicite:9]{index=9}
                intersection.add(num)

    return len(intersection)
if __name__ == '__main__':
    # 使用示例
    file1 = 'a.bin'
    file2 = 'b.bin'
    common_count = count_128bit_intersection(file1, file2)
    print(f"两个文件的128位块交集个数：{common_count}")
